<template>
  <div>
    <van-row>
      <van-col span="2"></van-col>
      <van-col span="20">

        <div style="margin-top: 100px;">
          <h1>修改密码</h1>
          <van-form >
            <van-cell-group inset>
              <van-field
                  clearable
                  v-model="user.phone"
                  label="手机号"
                  placeholder="请输入手机号"
                  :rules="[{ required: true, message: '请输入手机号' }]"
              />
              <van-field
                  v-model="user.password"
                  type="password"
                  label="新密码"
                  placeholder="请输入新密码"
                  :rules="[{ required: true, message: '请输入新密码' }]"
              />
              <van-field
                  v-model="newpass2"
                  type="password"
                  label="确认密码"
                  placeholder="请再次输入密码"
                  :rules="[{ required: true, message: '请输入确认密码' }]"
              />
            </van-cell-group>

            <div style="margin: 16px;">
              <van-button round block type="primary" @click="updatepass()">
                确认修改
              </van-button>
            </div>
          </van-form>
        </div>
      </van-col>
      <van-col span="2"></van-col>
    </van-row>

  </div>
</template>

<script>
import { ref } from 'vue';

export default {
  setup() {
  },
  data(){
    return{
		user:{
			phone: "",
			password: "",
		},
		newpass2:""
    }
  },methods:{
    //实现账号的密码修改
    updatepass(){
      var that=this;
      this.axios.post("auth/findupdatepass",this.user).then((res) => {
		  console.log(res)
        if(res.data.code==200){
			
			//更新令牌
		//	this.$store.commit("setToken",res.data.data);
			
          //可用
          this.$toast.success('密码修改成功，需要重新登录');
          this.$router.push("/login");
        }else{
          //存在，不可用
          this.$toast.fail('密码修改失败，请检查！');
        }
      });
    },
  }
}
</script>

<style>
</style>

